/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package service.impl;

import pojo.Reply;
import java.util.List;
import service.IReplyService;

/**
 *
 * @author Cong
 */
public class ReplyServiceImpl<T extends Reply> extends ServiceImpl<T> implements IReplyService<T> {

    public List<T> listReply(int threadId, int offset, int pageSize) {
        return this.getDao().list(
                " select r from Reply r "
                + " where r.thread.threadId = " + threadId + " order by r.replyDate asc",
                offset, pageSize, null);
    }

    public void createNewReply(T r) {
        this.getDao().create(r);
    }

    public int count(int threadID) {
        return this.getTotalCount("select count(r) from Reply r "
                + " where r.thread.threadId = " + threadID, null);
    }
}
